Skip to content

feat(avm)!: enable amm check circuit#16569

Merged
fcarreiro merged 1 commit intonextfrom
ir/08-25-feat_avm_enable_amm_check_circuit
Aug 29, 2025
Merged

feat(avm)!: enable amm check circuit#16569
fcarreiro merged 1 commit intonextfrom
ir/08-25-feat_avm_enable_amm_check_circuit

Conversation

@IlyasRidhuan
Copy link
Copy Markdown
Contributor

@IlyasRidhuan IlyasRidhuan commented Aug 25, 2025

Fixes identified in @dbanks12 PR here. Enables the AMM

## TX Label: Token/constructor/0
- Total duration: `203.016 ms`
- Total mana used: `310,167`
- Mana per second: `1,527,799`
- Total instructions executed: `18,095`
- Private insertions:
    - Non-revertible: `6.079 ms`
    - Revertible: `0.644 ms`
- Proving:
    - Simulation (all): `197 ms`
    - Trace generation (all): `1,932 ms`
    - Trace generation interactions: `1,089 ms`
    - Trace generation traces: `837 ms`
- Enqueued public calls:
    - **Fn: Token.constructor**
        - Duration: `170.886 ms`
        - Mana used: `310,167`
        - Mana per second: `1,815,048`
        - Instructions executed: `18,095`

---------------------------------------------------------------------

## TX Label: Token/constructor/1
- Total duration: `156.058 ms`
- Total mana used: `310,167`
- Mana per second: `1,987,515`
- Total instructions executed: `18,095`
- Private insertions:
    - Non-revertible: `3.979 ms`
    - Revertible: `0.368 ms`
- Proving:
    - Simulation (all): `226 ms`
    - Trace generation (all): `2,127 ms`
    - Trace generation interactions: `1,232 ms`
    - Trace generation traces: `889 ms`
- Enqueued public calls:
    - **Fn: Token.constructor**
        - Duration: `133.126 ms`
        - Mana used: `310,167`
        - Mana per second: `2,329,871`
        - Instructions executed: `18,095`

---------------------------------------------------------------------
## TX Label: Token/constructor/2
- Total duration: `148.063 ms`
- Total mana used: `310,167`
- Mana per second: `2,094,828`
- Total instructions executed: `18,095`
- Private insertions:
    - Non-revertible: `3.793 ms`
    - Revertible: `0.356 ms`
- Proving:
    - Simulation (all): `197 ms`
    - Trace generation (all): `1,944 ms`
    - Trace generation interactions: `1,067 ms`
    - Trace generation traces: `871 ms`
- Enqueued public calls:
    - **Fn: Token.constructor**
        - Duration: `128.718 ms`
        - Mana used: `310,167`
        - Mana per second: `2,409,667`
        - Instructions executed: `18,095`

---------------------------------------------------------------------

## TX Label: AMM/constructor/3
- Total duration: `69.322 ms`
- Total mana used: `42,927`
- Mana per second: `619,239`
- Total instructions executed: `2,035`
- Private insertions:
    - Non-revertible: `3.276 ms`
    - Revertible: `0.346 ms`
- Proving:
    - Simulation (all): `66 ms`
    - Trace generation (all): `677 ms`
    - Trace generation interactions: `112 ms`
    - Trace generation traces: `560 ms`
- Enqueued public calls:
    - **Fn: AMM.constructor**
        - Duration: `47.049 ms`
        - Mana used: `42,927`
        - Mana per second: `912,395`
        - Instructions executed: `2,035`

---------------------------------------------------------------------
## TX Label: AMM/set_minter/4
- Total duration: `30.908 ms`
- Total mana used: `11,014`
- Mana per second: `356,353`
- Total instructions executed: `623`
- Private insertions:
    - Non-revertible: `2.768 ms`
    - Revertible: `0.359 ms`
- Proving:
    - Simulation (all): `45 ms`
    - Trace generation (all): `969 ms`
    - Trace generation interactions: `135 ms`
    - Trace generation traces: `833 ms`
- Enqueued public calls:
    - **Fn: Token.set_minter**
        - Duration: `11.947 ms`
        - Mana used: `11,014`
        - Mana per second: `921,920`
        - Instructions executed: `623`

---------------------------------------------------------------------

## TX Label: AMM/add_liquidity/5
- Total duration: `141.487 ms`
- Total mana used: `135,912`
- Mana per second: `960,600`
- Total instructions executed: `7,755`
- Private insertions:
    - Non-revertible: `2.524 ms`
    - Revertible: `0.268 ms`
- Proving:
    - Simulation (all): `132 ms`
    - Trace generation (all): `1,822 ms`
    - Trace generation interactions: `439 ms`
    - Trace generation traces: `1,375 ms`
- Enqueued public calls:
    - **Fn: Token._increase_public_balance**
    
---------------------------------------------------------------------    

  ## TX Label: AMM/swap_exact_tokens_for_tokens/6
- Total duration: `86.802 ms`
- Total mana used: `86,181`
- Mana per second: `992,850`
- Total instructions executed: `5,048`
- Private insertions:
    - Non-revertible: `3.308 ms`
    - Revertible: `0.334 ms`
- Proving:
    - Simulation (all): `97 ms`
    - Trace generation (all): `1,622 ms`
    - Trace generation interactions: `301 ms`
    - Trace generation traces: `1,315 ms`
- Enqueued public calls:
    - **Fn: Token._increase_public_balance**
        - Duration: `15.557 ms`
        - Mana used: `17,146`
        - Mana per second: `1,102,164`
        - Instructions executed: `1,027`
    - **Fn: AMM._swap_exact_tokens_for_tokens**
        - Duration: `48.411 ms`
        - Mana used: `69,035`
        - Mana per second: `1,426,009`
        - Instructions executed: `4,021`

---------------------------------------------------------------------

## TX Label: AMM/remove_liquidity/7
- Total duration: `172.86 ms`
- Total mana used: `155,323`
- Mana per second: `898,546`
- Total instructions executed: `8,871`
- Private insertions:
    - Non-revertible: `2.936 ms`
    - Revertible: `0.291 ms`
- Proving:
    - Simulation (all): `145 ms`
    - Trace generation (all): `1,787 ms`
    - Trace generation interactions: `447 ms`
    - Trace generation traces: `1,332 ms`
- Enqueued public calls:
    - **Fn: Token._increase_public_balance**
        - Duration: `15.772 ms`
        - Mana used: `17,146`
        - Mana per second: `1,087,104`
        - Instructions executed: `1,027`
    - **Fn: AMM._remove_liquidity**
        - Duration: `134.25 ms`
        - Mana used: `138,177`
        - Mana per second: `1,029,252`
        - Instructions executed: `7,844`
        - Duration: `14.17 ms`
        - Mana used: `17,146`
        - Mana per second: `1,210,011`
        - Instructions executed: `1,027`
    - **Fn: Token._increase_public_balance**
        - Duration: `15.497 ms`
        - Mana used: `17,146`
        - Mana per second: `1,106,437`
        - Instructions executed: `1,027`
    - **Fn: AMM._add_liquidity**
        - Duration: `91.271 ms`
        - Mana used: `101,620`
        - Mana per second: `1,113,387`
        - Instructions executed: `5,701`

---------------------------------------------------------------------

Copy link
Copy Markdown
Contributor Author

IlyasRidhuan commented Aug 25, 2025

// The initial next_context_id = 2, in row = 1
#[INCR_NEXT_CONTEXT_ID]
NOT_LAST_EXEC * (next_context_id' - (next_context_id + sel_enter_call)) = 0;
NOT_LAST_EXEC * (next_context_id' - (next_context_id + sel_enter_call + enqueued_call_start')) = 0;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken from here

pol PROPAGATE_CALL_ID = 1 - RESET_NEXT_CALL_ID - NEW_NEXT_CALL_ID;
// This is an XOR
pol RESET_OR_NEW_NEXT_CALL_ID = (RESET_NEXT_CALL_ID + NEW_NEXT_CALL_ID) - (RESET_NEXT_CALL_ID * NEW_NEXT_CALL_ID);
pol PROPAGATE_CALL_ID = 1 - RESET_OR_NEW_NEXT_CALL_ID;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From here, RESET_NEXT_CALL_ID and NEW_NEXT_CALL_ID weren't mutually exclusive.

@IlyasRidhuan IlyasRidhuan marked this pull request as ready for review August 25, 2025 15:32
@IlyasRidhuan IlyasRidhuan requested review from dbanks12 and removed request for Maddiaa0, fcarreiro and jeanmon August 25, 2025 15:32
Copy link
Copy Markdown
Contributor

@dbanks12 dbanks12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines 10 to 14

// TODO: unskip when check-circuit works for AMM. Confirm that it is fast enough to run in CI.
describe.skip('AVM proven AMM', () => {
describe('AVM proven AMM', () => {
const logger = createLogger('avm-proven-tests-amm');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove TODO

@IlyasRidhuan IlyasRidhuan changed the base branch from ir/08-25-fix_avm_last_child_id_constraints to graphite-base/16569 August 27, 2025 15:17
@IlyasRidhuan IlyasRidhuan force-pushed the ir/08-25-feat_avm_enable_amm_check_circuit branch from 1b08a64 to aa3b8ab Compare August 27, 2025 15:21
@IlyasRidhuan IlyasRidhuan changed the base branch from graphite-base/16569 to ir/08-25-fix_avm_last_child_id_constraints August 27, 2025 15:21
@IlyasRidhuan IlyasRidhuan force-pushed the ir/08-25-fix_avm_last_child_id_constraints branch from 9093797 to b3ed32f Compare August 28, 2025 08:16
@IlyasRidhuan IlyasRidhuan force-pushed the ir/08-25-feat_avm_enable_amm_check_circuit branch from aa3b8ab to 0aee87a Compare August 28, 2025 08:16
@IlyasRidhuan IlyasRidhuan changed the base branch from ir/08-25-fix_avm_last_child_id_constraints to graphite-base/16569 August 29, 2025 09:35
@IlyasRidhuan IlyasRidhuan force-pushed the ir/08-25-feat_avm_enable_amm_check_circuit branch from 0aee87a to e7e6e48 Compare August 29, 2025 13:46
@IlyasRidhuan IlyasRidhuan changed the base branch from graphite-base/16569 to next August 29, 2025 13:46
@IlyasRidhuan IlyasRidhuan force-pushed the ir/08-25-feat_avm_enable_amm_check_circuit branch from e7e6e48 to 80bad67 Compare August 29, 2025 14:39
@fcarreiro fcarreiro added this pull request to the merge queue Aug 29, 2025
Merged via the queue into next with commit db151be Aug 29, 2025
15 checks passed
@fcarreiro fcarreiro deleted the ir/08-25-feat_avm_enable_amm_check_circuit branch August 29, 2025 16:08
ludamad pushed a commit that referenced this pull request Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants